#pragma once
#include "ZerglingBloodMacros.h"
#include <BWAPI.h>
class DropShipManager
{
public:
	DropShipManager();
	DropShipManager(BWAPI::Unit* dp, BWAPI::Game * BW);
	
	bool isHarassing()
	{
		return ship_state == HARASS;
	}

	//Starts scouting all bases and returns to starting position
	void scoutBases();

	//Called every 25 frames
	void shipSlowFrame();
	
	//Called every frame
	void shipFastFrame();

	//User should check if ship is available first
	void requestShip(BWAPI::Position rq);

	//Given a hero it will harras until the ship is requested,
	//or the hero dies. Ship stays available
	void harass(BWAPI::Unit * h);

	//Picks up the hero
	void twoWayPickup();
	void pickup();

private: 
	BWAPI::Game* Broodwar;
	BWAPI::Unit* dropShip;
	bool availabe;
	int ship_state;
	enum ship_states{SCOUTING, WAITING, HARASS, REQUESTED};

	/*Scouting*/
	int first_base;
	int curr_base;
	int getNextBase(int curr);
	BWAPI::Position scout_start;

	/*Request*/
	BWAPI::Position req_pos;

	/*Harass*/
	BWAPI::Position harass_start;
	BWAPI::Unit* hero;
	int harass_state;
	//Number of frames it takes to attack
	int attack_frames;
	int weapon_range;
	enum harass_states{DONE,PU, PUR, DD, HARASSUP, SEARCHING, CLOSING, HARASSDOWN};
	//Heat map has a higher value for tiles with more zerglings.
	std::map<BWAPI::TilePosition, int> heat_map;
	bool found_safe;
	BWAPI::Position safe_pos;
	//Fills the heat map starting at position covering a dis x dis square centered at
	//position
	void makeHeatMap(BWAPI::TilePosition pos, int dis);

	void kerriganHarass();
	bool stormed;

	BWAPI::Position getSplashSide(BWAPI::TilePosition pos, int dis);

	/*Helper Functions*/
	BWAPI::Position getBasePos(int b);
	void goClosestBase();

	bool isGamePlayer(const BWAPI::Color & player_color)
	{
		return (player_color == COLOR_RED || player_color == COLOR_BLUE || player_color == COLOR_TEAL ||
		   player_color == COLOR_ORANGE || player_color == COLOR_BROWN || player_color == COLOR_PURPLE);
	}

	int unitSetSize(std::set<BWAPI::Unit*> units);
	
	//Returns true if done scouting
	bool checkScout();


	

};